#coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
#https://blog.csdn.net/weixin_40702722/article/details/79910471
# https://www.jianshu.com/p/a94918d49c3c
import time

options = webdriver.FirefoxOptions()
# options.add_argument('-headless')
driver = webdriver.Firefox(options=options)



driver.get("http://www.baidu.com")
# 等待时长10秒，默认0.5秒询问一次
print(WebDriverWait(driver,10).until(EC.title_is(u"百度一下，你就知道")))
'''判断title,返回布尔值'''
WebDriverWait(driver,10).until(EC.title_contains(u"百度一下"))
'''判断title，返回布尔值'''

WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID,'kw')))
'''判断某个元素是否被加到了dom树里，并不代表该元素一定可见，如果定位到就返回WebElement'''

abc=WebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'.mnav')))
'''判断是否至少有1个元素存在于dom树中，如果定位到就返回列表'''
print(abc)

